local timebombSkill = fk.CreateSkill {
  name = "timebomb_skill",
}

timebombSkill:addEffect("cardskill", {
  prompt = "#timebomb_skill",
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player
  end,
  target_filter = Util.CardTargetFilter,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = effect.to
    local judge = {
      who = to,
      reason = "timebomb",
      pattern = ".|.|spade",
    }
    room:judge(judge)
    local throw = true
    if judge:matchPattern() then
      room:damage { from = nil, to = to, damage = 2, card = effect.card, skillName = self.name,
      damageType = (math.random(1, 2) == 1 and fk.FireDamage or fk.ThunderDamage) }
    elseif not to.dead and not table.contains(to.sealedSlots, Player.JudgeSlot) and not to:hasDelayedTrick("timebomb") then
      throw = false
      local cards = room:getSubcardsByRule(effect.card, { Card.Processing })
      if #cards > 0 then
        if effect.card:isVirtual() then
          to:addVirtualEquip(effect.card)
        end
        room:moveCards{
          ids = cards,
          to = effect.to,
          toArea = Card.PlayerJudge,
          moveReason = fk.ReasonPut,
        }
      end
    end
    if throw then
      self:onNullified(room, effect)
    end
  end,
  on_nullified = function(self, room, effect)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse
    }
  end,
})

Fk:loadTranslationTable{
  ["timebomb_skill"] = "定时炸弹",
  ["#timebomb_skill"] = "给目标角色安置炸弹，其每回合都判定，直到结果为♠受到2点伤害",
}


return timebombSkill
